<template>
  <div>
    <el-menu
        style="width:200px; min-height: calc(100vh - 50px);"
        :default-active="path"
        router
        active-text-color="#ffd04b"
        background-color="#545c64"
        text-color="#fff"
    >
      <el-menu-item index="/user" >
        <template #title>
          <el-icon><Setting /></el-icon>
          <span>用户管理</span>
        </template>
      </el-menu-item>

      <el-menu-item index="/book">
        <el-icon><Notebook /></el-icon>
        <span>书籍管理</span>
      </el-menu-item>

      <el-menu-item index="/news">
        <el-icon><ChatDotSquare /></el-icon>
        <span>书评管理</span>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script>
import {ArrowDown} from "@element-plus/icons-vue";
import {Location,Document,Menu as IconMenu,Notebook ,Setting,ChatDotSquare} from '@element-plus/icons';
import request from "../../utils/request";

export default {
  name: "Aside",
  data() {
    return {
      user: {},
      path: this.$route.path    //设置默认高亮的菜单
    }
  },
  created() {
    let userStr = sessionStorage.getItem("user") || "{}"
    this.user = JSON.parse(userStr)

    //请求服务器端,确认与当前用户的合法信息
    request.get("api/user/" + this.user.id).then(res => {
      if (res.code === '0') {
        this.user = res.data
      }
    })
  },
  components:{
    ArrowDown,
    Location,
    Document,
    Setting,
    Notebook ,
    ChatDotSquare,
    IconMenu
  }
}


</script>

<style scoped>

</style>